<extend name="Public/base"/>

<block name="body">
<style type="text/css">
	.controls select{
		width:16.67%;
		float: left;
	}
	</style>
    <div class="main-title">
        <h2>新增学校</h2>
    </div>
    <form action="{:U(save)}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">学校名称</label>
            <div class="controls">
                <input type="text" class="text input-large" name="schoolname" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">学校拼音简称<span class="check-tips">（不能改）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="school_short_name" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">学校所在地区<span class="check-tips">（不能改）</span></label>
            <div class="controls">
                <select class="form-control" name="provinceid" id="J_province"></select>
                <select class="form-control"  name="cityid" id="J_city" style="display:none;"></select>
                <select class="form-control"  name="areaid" id="J_district" style="display:none;"></select>
            </div>
        </div>
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('School/index')}');
$(function(){
    var pid=<if condition="$param.province neq ''">{$param.province}<else />0</if>;  //默认省份id
    var cid=<if condition="$param.city neq ''">{$param.city}<else />0</if>;  //默认城市id
    var did=<if condition="$param.district neq ''">{$param.district}<else />0</if>;  //默认区县市id

    /*修复联动不及时的bug，陈一枭*/
	function change_province(pid){
        $.post("{:addons_url('ChinaCity://ChinaCity/getProvince')}", {pid: pid}, function(result){
            $("#J_province").html(result);
        });
    }

	function change_city(p_pid,p_cid){
	    $.post('{:addons_url("ChinaCity://ChinaCity/getCity")}', {pid: p_pid, cid: p_cid}, function(result){
	        $("#J_city").show().html(result);
	    });
	}
	function change_district(p_cid,p_did){
	    $.post('{:addons_url("ChinaCity://ChinaCity/getDistrict")}', {cid: p_cid, did: p_did}, function(result){
	        $("#J_district").show().html(result);
	    });
	}

    change_province(pid);
    change_city(pid,cid);
    change_district(cid,did);


    $('#J_province').change(function(){
        var pid_g=$(this).children('option:selected').val();
        change_city(pid_g)
        change_district(0);

    });

    $('#J_city').change(function(){
        var cid_g=$(this).children('option:selected').val();
        change_district(cid_g)


    });

    $('#J_district').change(function(){
        var did_g=$(this).children('option:selected').val();
    });

});
    </script>
</block>
